#include<bits/stdc++.h>
using namespace std;
int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<48||ch>57){if(ch=='-') f=-1;ch=getchar();}
	while(ch>=48&&ch<=57) x=x*10+ch-48,ch=getchar();
	return x*f;
}
int t,n,a[1000005],b[2000005]; 
char ans[1000005];
struct node
{
	string s;
	int id;
} s[100000];
string ch;
bool cmp(node a,node b)
{
	return a.s<b.s;
}
int check()
{
	ch=ans[n];
	s[n].id=n,s[n].s=ch;
	for(int i=n-1;i>=1;--i)
	   s[i].id=i,ch=ans[i]+ch,s[i].s=ch;
	sort(s+1,s+1+n,cmp);
	for(int i=1;i<=n;++i)
	   if(i!=a[s[i].id]) return 1;
	return 1;
}
int main()
{
	freopen("string.in","r",stdin);
	freopen("string.out","w",stdout);
	t=read();
	while(t--)
	{
		n=read();
		for(int i=1;i<=n;++i)
		   a[i]=read()+1;
		for(int i=1;i<2*n;++i) b[i]=read();
		ans[1]='a';
		int fl=0;
		for(int i=2;i<2*n;i+=2)
		   if(b[i])
		   {
		   	for(int j=0;j<b[i]/2;++j)
		   	if(i/2-j>=1) ans[i/2+j+1]=ans[i/2-j];
		    else
		    {
		    	cout<<"-1\n";
		    	fl=1;
		    	break;
			}
		   }
		   else 
		   {
		   	if(ans[i/2]=='a') ans[i/2+1]='b';
		   	else ans[i/2+1]='a';
		   }
		if(fl) continue;
		if(check())
		{
			for(int i=1;i<=n;++i)
			   cout<<ans[i];
			cout<<"\n";
		}
		else
		{
			for(int i=1;i<=n;++i)
			   if(ans[i]=='a') ans[i]='b';
			   else ans[i]='a';
			if(check())
			{
				for(int i=1;i<=n;++i)
				   cout<<ans[i];
				cout<<"\n";
			}
			else
			{
				cout<<"-1\n";
			}
		}
	}
	return 0;
}

